﻿using FluentNHibernate.Mapping;
using NH.Core.Model;

namespace NH.Data.Mappings
{
    public class CategoryMap : ClassMap<Category>
    {
        public CategoryMap()
        {
            Id(c => c.Id).GeneratedBy.Native();
            Map(c => c.Name).Unique().Not.Nullable();

            HasMany(c => c.Products)
                .KeyColumn("CategoryId")
                .Cascade.AllDeleteOrphan()
                .Inverse();
        }
    }
}